*****************************************************************
* The Dodd-Frank Act and Conflict in Africa's Great Lake Region *
*****************************************************************

* Enforcement suspension analysis

* Set working directory
cd "C:\Users\jeffrey.bloem\OneDrive - USDA\Dodd Frank\Dodd Frank\Replication files\Enforcement suspension"

* Load Raw ACLED data
clear
import excel "raw_acled_14_18.xlsx", sheet("raw_acled_14_18") firstrow
tostring month, gen(month_str) format("%02.0f")
egen month_year = concat(month_str year) 

gen admin2_n = 1
gen civilians = 1 if event_type=="Violence against civilians"
gen battles = 1 if event_type=="Battle-Government regains territory" | ///
event_type=="Battle-No change of territory" | event_type=="Battle-Non-state actor overtakes territory" 
gen riots_protest = event_type=="Riots/Protests"
gen other = 1 if event_type=="Headquarters or base established" | ///
event_type=="Non-violent transfer of territory" | event_type=="Remote violence" | ///
event_type=="Strategic development"

* clean
replace admin2="Maseru" if country=="Lesotho" & admin1=="Maseru" & admin2==""
replace admin2="Leribe" if country=="Lesotho" & admin1=="Leribe" & admin2==""
replace admin2="Berea" if country=="Lesotho" & admin1=="Berea" & admin2==""
replace admin2="Butha-Buthe" if country=="Lesotho" & admin1=="Butha-Buthe" & admin2==""
replace admin2="Mokhotlong" if country=="Lesotho" & admin1=="Mokhotlong" & admin2==""
replace admin2="Mafeteng" if country=="Lesotho" & admin1=="Mafeteng" & admin2==""
replace admin2="Misraq Gojjam" if country=="Ethiopia" & admin1=="Amhara" & admin2=="East Gojjam Zone"
replace admin2="Semen Wello" if country=="Ethiopia" & admin1=="Amhara" & admin2=="North Wollo Zone"
replace admin2="Ainamoi" if country=="Kenya" & admin1=="Kericho" & admin2=="Musaria"
replace admin2="Nyaribari Masaba" if country=="Kenya" & admin1=="Kisii" & admin2=="Kenyenya"
replace admin2="Abuja Municipality" if country=="Nigeria" & admin1=="Federal Capital Territory" & admin2=="Abuja Municipal"
replace admin1="Sud-Kivu" if country=="Democratic Republic of Congo" & admin1=="Maniema" & admin2=="Sud-Kivu"
replace admin1="Sud-Kivu" if country=="Democratic Republic of Congo" & admin1=="Kasai-Occidental" & admin2=="Sud-Kivu"
replace admin2="Kukawa" if country=="Nigeria" & admin1=="Borno" & admin2=="Baga"
replace admin2="Calabar-Municipal" if country=="Nigeria" & admin1=="Cross River" & admin2=="Calabar Municipal"
replace admin2="Port-Harcourt" if country=="Nigeria" & admin1=="Rivers" & admin2=="Port Harcourt"
replace admin1="Kibale" if country=="Uganda" & admin1=="Kakumiro" & admin2=="Bugangaizi"
replace admin2="Isoka" if country=="Zambia" & admin1=="Muchinga" & admin2=="Mafinga"
replace admin2="Owerri-Municipal" if country=="Nigeria" & admin1=="Imo" & admin2=="Owerri Municipal"
replace admin2="Zangon-Kataf" if country=="Nigeria" & admin1=="Kaduna" & admin2=="Zango-Kataf"
replace admin2="Butaganzwa" if country=="Burundi" & admin1=="Kayanza" & admin2=="Butaganzwa1"
replace admin2="Wayi" if country=="Chad" & admin1=="Lac" & admin2=="Fouli"
replace admin1="Bushenyi" if country=="Uganda" & admin1=="Sheema" & admin2=="Sheema"
replace admin2="Birnin-Gwari" if country=="Nigeria" & admin1=="Kaduna" & admin2=="Birnin Gwari"
replace admin2="Keran" if country=="Togo" & admin1=="Kara" & admin2=="Dankpen"
replace admin1="Nord-Kivu" if country=="Democratic Republic of Congo" & admin1=="Sud-Kivu" & admin2=="Goma"
replace admin2="Mwenge" if country=="Uganda" & admin1=="Kyenjojo" & admin2=="Kihuura"
replace admin2="Lusaka" if country=="Zambia" & admin1=="Lusaka" & admin2=="Chilanga"
replace admin2="Logone-Et-Chari" if country=="Cameroon" & admin1=="Extreme-Nord" & admin2=="Logone-et-Chari"
replace admin2="Bujumbura" if country=="Uganda" & admin1=="Rukungiri" & admin2=="Bufumbira"
replace admin2="Rohero" if country=="Burundi" & admin1=="Bujumbura Mairie" & admin2=="Roherero"
replace admin2="Tchaudjo" if country=="Togo" & admin1=="Centre" & admin2=="Mo"
replace admin2="Tolon-Kumbungu" if country=="Ghana" & admin1=="Northern" & admin2=="Tolon/Kumbungu"
replace admin2="Hohoe" if country=="Ghana" & admin1=="Volta" & admin2=="Afadjato South"
replace admin1="Dowa" if country=="Malawi" & admin1=="Central Region" & admin2=="Dowa"
replace admin2="Dowa Boma" if country=="Malawi" & admin1=="Dowa" & admin2=="Dowa"
replace admin2="Wedza" if country=="Zimbabwe" & admin1=="Mashonaland East" & admin2=="Hwedza"
replace admin2="Marondera" if country=="Zimbabwe" & admin1=="Mashonaland East" & admin2=="Marondera Urban"
replace admin2="Aowin-Suaman" if country=="Ghana" & admin1=="Western" & admin2=="Aowin"
replace admin2="Douentza" if country=="Mali" & admin1=="Mopti" & admin2=="Mondoro"
replace admin2="Ikpoba-Okha" if country=="Nigeria" & admin1=="Edo" & admin2=="Ikpoba Okha"
replace admin2="Obafemi-Owode" if country=="Nigeria" & admin1=="Ogun" & admin2=="Obafemi Owode"
replace admin2="Harare" if country=="Zimbabwe" & admin1=="Harare" & admin2=="Chitungwiza"
replace admin2="Harare" if country=="Zimbabwe" & admin1=="Harare" & admin2=="Epworth"
replace admin2="Gwanda" if country=="Zimbabwe" & admin1=="Matabeleland South" & admin2=="Gwanda Urban"
replace admin2="Gweru" if country=="Zimbabwe" & admin1=="Midlands" & admin2=="Gweru Urban"
replace admin2="St. Paul River" if country=="Liberia" & admin1=="Montserrado" & admin2=="St Paul River"
replace admin2="Zangon-Kataf" if country=="Nigeria" & admin1=="Kaduna" & admin2=="Zangon Kataf"
replace admin2="Danko Wasagu" if country=="Nigeria" & admin1=="Kebbi" & admin2=="Wasagu/Danko"
replace admin2="Imeko Afon" if country=="Nigeria" & admin1=="Ogun" & admin2=="Imeko-Afon"
replace admin2="Chipinge" if country=="Zimbabwe" & admin1=="Manicaland" & admin2=="Chipinge Urban"
replace admin2="Basa-Fleuve" if country=="Democratic Republic of Congo" & admin1=="Bas-Congo" & admin2=="Bas-Fleuve"
replace admin2="Emohua" if country=="Nigeria" & admin1=="Rivers" & admin2=="Emuoha"
replace admin2="Sekyere" if country=="Ghana" & admin1=="Ashanti" & admin2=="Sekyere East"
replace admin2="Zangon-Kataf" if country=="Nigeria" & admin1=="Kaduna" & admin2=="Zagon Kataf"
replace admin2="Mugongo-Manga" if country=="Burundi" & admin1=="Bujumbura Rural" & admin2=="Mugongomanga"
replace admin2="Vallee du Ntem" if country=="Cameroon" & admin1=="Sud" & admin2=="Ntem"
replace admin2="Calabar-South" if country=="Nigeria" & admin1=="Cross River" & admin2=="Calabar South"
replace admin2="Kadoma" if country=="Zimbabwe" & admin1=="Mashonaland West" & admin2=="Kadoma Urban"
replace admin1="Lira" if country=="Uganda" & admin1=="Amolatar" & admin2=="Kioga"
replace admin2="Kyoga" if country=="Uganda" & admin1=="Lira" & admin2=="Kioga"
replace admin1="Mukono" if country=="Uganda" & admin1=="Wakiso" & admin2=="Mukono"
replace admin2="Mutare" if country=="Zimbabwe" & admin1=="Manicaland" & admin2=="Mutare Urban"
replace admin2="Makonde" if country=="Zimbabwe" & admin1=="Mashonaland West" & admin2=="Chinhoyi"
replace admin2="Hwange" if country=="Zimbabwe" & admin1=="Matabeleland North" & admin2=="Victoria Falls"
replace admin2="Kamashi" if country=="Ethiopia" & admin1=="Benshangul-Gumaz" & admin2=="Kamashi Zone"
replace admin2="West Akim" if country=="Ghana" & admin1=="Eastern" & admin2=="Upper West Akim"
replace admin1="Grand Cape Mount" if country=="Liberia" & admin1=="Grand Bassa" & admin2=="Commonwealth B"
replace admin2="Commonwealth" if country=="Liberia" & admin1=="Grand Cape Mount" & admin1=="Commonwealth B"
replace admin2="Barrobo" if country=="Liberia" & admin1=="Maryland" & admin2=="Harper"
replace admin2="Ile" if country=="Mozambique" & admin1=="Zambezia" & admin2=="Mulevala"
replace admin2="Busiro" if country=="Uganda" & admin1=="Wakiso" & admin2=="Busiiro"
replace admin2="Bulilima" if country=="Zimbabwe" & admin1=="Matabeleland South" & admin2=="Bulilima (North)"
replace admin2="Kemashi" if country=="Ethiopia" & admin1=="Benshangul-Gumaz" & admin2=="Kamashi"
replace admin2="Commonwealth" if country=="Liberia" & admin1=="Grand Cape Mount" & admin2=="Commonwealth B"
replace admin2="Kanyosha" if country=="Burundi" & admin1=="Bujumbura Mairie" & admin2=="Kanyosha1"
replace admin1="Pallisa" if country=="Uganda" & admin1=="Budaka" & admin2=="Budaka"
replace admin1="Masaka" if country=="Uganda" & admin1=="Lwengo" & admin2=="Bukoto"
replace admin2="Gokwe South" if country=="Zimbabwe" & admin1=="Midlands" & admin2=="Gokwe South Urban"
replace admin2="Kanyosha" if country=="Burundi" & admin1=="Bujumbura Mairie" & admin2=="Kanyosha2"
replace admin2="Kibwezi" if country=="Kenya" & admin1=="Makueni" & admin2=="Kibwezi West"
replace admin2="Ruaraka" if country=="Kenya" & admin1=="Nairobi" & admin2=="Baba Dogo"
replace admin1="Adamawa" if country=="Nigeria" & admin1=="Borno" & admin2=="Madagali"
replace admin2="Badhan" if country=="Somalia" & admin1=="Sanaag" & admin2=="Haylan"
replace admin2="Kadoma" if country=="Zimbabwe" & admin1=="Mashonaland West" & admin2=="Sanyati"
replace admin2="Kwekwe" if country=="Zimbabwe" & admin1=="Midlands" & admin2=="Kwekwe Urban"
replace admin2="M'Banza Congo" if country=="Angola" & admin1=="Zaire" & admin2=="MBanza Congo"
replace admin2="Quissenge" if country=="Mozambique" & admin1=="Cabo Delgado" & admin2=="Quissanga"
replace admin2="Hurungwe" if country=="Zimbabwe" & admin1=="Mashonaland West" & admin2=="Karoi"
replace country="Mali" if country=="Burkina Faso" & admin1=="Gao" & admin2=="Gao"
replace admin2="Savelugu Nanton" if country=="Ghana" & admin1=="Northern" & admin2=="Savelugu/Nanton"
replace admin2="Jasikan" if country=="Ghana" & admin1=="Volta" & admin2=="Biakoye"
replace admin2="Mpohor Wassa East" if country=="Ghana" & admin1=="Western" & admin2=="Mpohor/Wassa East"
replace admin2="Nioro du Rip" if country=="Senegal" & admin1=="Kaolack" & admin2=="Nioro Du Rip"
replace admin2="Lamwo" if country=="Uganda" & admin1=="Kitgum" & admin2=="Labongo Amida"
replace admin2="Masvingo" if country=="Zimbabwe" & admin1=="Masvingo" & admin2=="Masvingo Urban"
replace admin2="Bulilima" if country=="Zimbabwe" & admin1=="Matabeleland South" & admin2=="Plumtree"
replace admin1="Alibori" if country=="Benin" & admin1=="Atakora" & admin2=="Malanville"
replace admin2="Atwima" if country=="Ghana" & admin1=="Ashanti" & admin2=="Atwima Nwabiagya"
replace admin1="Siaya" if country=="Kenya" & admin1=="Migori" & admin2=="Kaluoch"
replace admin2="Gem" if country=="Kenya" & admin1=="Siaya" & admin2=="Kaluoch"
replace admin2="Pleebo/Sodeken" if country=="Liberia" & admin1=="Maryland" & admin2=="Pleebo/Sodoken"
replace admin2="Lilongwe City" if country=="Malawi" & admin1=="Lilongwe" & admin2=="TA Nsundwe"
replace admin2="Kitanda" if country=="Uganda" & admin1=="Bukomansimbi" & admin2=="Bukomansimbi"
replace admin1="Kabale" if country=="Uganda" & admin1=="Kigezi" & admin2=="Rukiga"
replace admin1="Kasai-Oriental" if country=="Democratic Republic of Congo" & admin1=="Kasai-Occidental" & admin2=="Tshilenge"
replace admin1="Edo" if country=="Nigeria" & admin1=="Ondo" & admin2=="Ovia North East"
replace admin2="Chegutu" if country=="Zimbabwe" & admin1=="Mashonaland West" & admin2=="Chegutu Urban"
replace admin2="Sekyere" if country=="Ghana" & admin1=="Ashanti" & admin2=="Sekyere Afram Plains"
replace admin2="Tappita" if country=="Liberia" & admin1=="Nimba" & admin2=="Kparblee"
replace admin2="Sanniquelleh-Mahn" if country=="Liberia" & admin1=="Nimba" & admin2=="Meinpea-Mahn"
replace admin1="Manicaland" if country=="Zimbabwe" & admin1=="Masvingo" & admin2=="Chipinge Urban"
replace admin2="Chipinge" if country=="Zimbabwe" & admin1=="Manicaland" & admin2=="Chipinge Urban"
replace admin2="Manica" if country=="Mozambique" & admin1=="Manica" & admin2=="Chipungabeira"
replace admin2="Manica" if country=="Mozambique" & admin1=="Manica" & admin2=="Nhacolo"
replace admin1="Bushenyi" if country=="Uganda" & admin1=="Rubirizi" & admin2=="Rubirizi"
replace admin2="Bunyaruguru" if country=="Uganda" & admin1=="Bushenyi" & admin2=="Rubirizi"
replace country="Guinea" if country=="Ivory Coast" & admin1=="Nzerekore" & admin2=="Lola"
replace admin2="Isiala-Ngwa North" if country=="Nigeria" & admin1=="Abia" & admin2=="Isiala Ngwa North"
replace admin2="Isiala-Ngwa South" if country=="Nigeria" & admin1=="Abia" & admin2=="Isiala Ngwa South"
replace admin2="Central So. Red-Sea" if country=="Eritrea" & admin1=="Debubawi Keyih Bahri" & admin2=="Denkalya Central"
replace admin2="Mambah-Kaba" if country=="Liberia" & admin1=="Margibi" & admin2=="Mambah Kaba"
replace admin2="Kanyosha1" if country=="Burundi" & admin1=="Bujumbura Rural" & admin2=="Kanyosha2"
replace admin2="Narok East" if country=="Kenya" & admin1=="Narok" & admin2=="Trans Mara East"
replace admin1="River Cess" if country=="Liberia" & admin1=="Rivercess" & admin2=="Timbo"
replace admin2="Seke" if country=="Zimbabwe" & admin1=="Mashonaland East" & admin2=="Ruwa"
replace admin2="Ketu" if country=="Ghana" & admin1=="Volta" & admin2=="Keta"
replace admin2="Akwapim North" if country=="Ghana" & admin1=="Eastern" & admin2=="Akuapim North"
replace admin2="Commonwealth" if country=="Liberia" & admin1=="Grand Cape Mount" & admin2=="Commonwealth C"
replace admin1="Grand Cape Mount" if country=="Liberia" & admin1=="Montserrado" & admin2=="Commonwealth"
replace admin2="Pailoro" if country=="Nigeria" & admin1=="Niger" & admin2=="Paikoro"
replace admin2="Gola Konneh" if country=="Liberia" & admin1=="Grand Cape Mount" & admin2=="Golakonneh"
replace admin2="Kariba" if country=="Zimbabwe" & admin1=="Mashonaland West" & admin2=="Kariba Urban"
replace admin1="Adamawa" if country=="Nigeria" & admin1=="Borno" & admin2=="Michika"
replace admin2="Kindia" if country=="Guinea" & admin1=="Kindia" & admin2=="Dar es Salam"
replace admin1="GrandKru" if country=="Liberia" & admin1=="Grand Kru" & admin2=="Barclayville"
replace admin2="Buah" if country=="Liberia" & admin1=="GrandKru" & admin2=="Barclayville"
replace admin2="Sussundega" if country=="Mozambique" & admin1=="Manica" & admin2=="Sussundenga"
replace admin2="Sanniquelleh-Mahn" if country=="Liberia" & admin1=="Nimba" & admin2=="Sanniquellie Mahn"

collapse (sum) admin2_n civilians battles riots_protest other fatalities, by(year month_str country admin1 admin2)

save "es_admin2_conflict_all.dta", replace

* Merge with full list of geographies 
use "\es_admin2_conflict_all.dta", clear

gen group=1 if country=="Uganda" | country=="Rwanda" | country=="Burundi" | ///
country=="Tanzania" |  | country=="Zambia" | ///
country=="Angola" | country=="Republic of Congo" | ///
country=="Central African Republic" | country=="Democratic Republic of Congo"
replace group=0 if country=="Kenya" | country=="Ethiopia" | country=="Chad" | ///
country=="Cameroon" | country=="Gabon" | country=="Mozambique" | country=="Malawi" | ///
country=="Botswana" | country=="Namibia" | country=="Zimbabwe" | country=="South Africa" | ///
country=="Nigeria" | country=="Senegal" | country=="Guinea" | country=="Sierra Leone" | ///
country=="Liberia" | country=="Ivory Coast" | country=="Ghana" | country=="Gambia" | ///
country=="Guinea-Bissau" | country=="Togo" | country=="Benin" | country=="Burkina Faso" | ///
country=="Eritrea" | country=="Djibouti" | country=="Somalia" | country=="Lesotho" | ///
country=="Swaziland" | country=="Niger" | country=="Mali"
drop if group==.

rename month_str (month)
tostring year, gen(year_str)
drop year
rename year_str (year)
egen year_month = concat(year month)
destring year, replace
destring month, replace

egen panel = group(year_month)
su panel, meanonly

* Generate all files
	foreach i of num 1/`r(max)' {
	preserve
	keep if panel==`i'
	save "files\admin2_conflict_`i'.dta", replace
	restore
	}
*

* Merge each file with full list of geographies
import excel "sample geographies.xlsx", sheet("Sheet1") firstrow clear
save "sample_geographies.dta", replace
use "sample_geographies.dta", clear

	foreach i of num 1/53 {
	preserve
	merge 1:1 country admin1 admin2 using "files\admin2_conflict_`i'.dta"
	rename (admin2_n) conflict_count
	replace conflict_count=0 if conflict_count==.
	replace fatalities=0 if fatalities==.
	replace civilians=0 if civilians==.
	replace battles=0 if battles==.
	replace riots_protest=0 if riots_protest==.
	replace other=0 if other==.
	egen year_hold = max(year)
	egen month_hold = max(month)
	drop year month 
	rename (year_hold) year
	rename (month_hold) month
	save "files\admin2_conflict_`i'.dta", replace
	restore
	}
*

* Append all files together
clear
	foreach i of num 1/53 {
	append using "files\admin2_conflict_`i'.dta"
	}
*

save "es_conflict_panel.dta", replace

******************
* Trends Figure **
******************
use "es_conflict_panel.dta", clear

* DRC only
drop group

gen group=1 if country=="Democratic Republic of Congo"
replace group=0 if country=="Kenya" | country=="Ethiopia" | country=="Chad" | ///
country=="Cameroon" | country=="Gabon" | country=="Mozambique" | country=="Malawi" | ///
country=="Botswana" | country=="Namibia" | country=="Zimbabwe" | country=="South Africa" | ///
country=="Nigeria" | country=="Senegal" | country=="Guinea" | country=="Sierra Leone" | ///
country=="Liberia" | country=="Ivory Coast" | country=="Ghana" | country=="Gambia" | ///
country=="Guinea-Bissau" | country=="Togo" | country=="Benin" | country=="Burkina Faso" | ///
country=="Eritrea" | country=="Djibouti" | country=="Somalia" | country=="Lesotho" | ///
country=="Swaziland" | country=="Niger" | country=="Mali"
drop if group==.

gen conflict_flag=1 if conflict_count>0
replace conflict_flag=0 if conflict_flag==.
gen civilians_flag=1 if civilians>0
replace civilians_flag=0 if civilians==0
gen battles_flag=1 if battles>0
replace battles_flag=0 if battles==0
gen riots_protest_flag=1 if riots_protest>0
replace riots_protest_flag=0 if riots_protest==0
gen other_flag=1 if other>0
replace other_flag=0 if other==0
gen deadly_conflict_flag=1 if fatalities>0
replace deadly_conflict_flag=0 if fatalities==0

collapse (mean) conflict_flag civilians_flag battles_flag riots_protest_flag ///
other_flag deadly_conflict_flag, by(year month group)

save "es_drc_trends.dta", replace

use "es_conflict_panel.dta", clear

* All covered countries 
drop group

gen group=1 if country=="Uganda" | country=="Rwanda" | country=="Burundi" | ///
country=="Tanzania" |  | country=="Zambia" | ///
country=="Angola" | country=="Republic of Congo" | ///
country=="Central African Republic" | country=="Democratic Republic of Congo"
replace group=0 if country=="Kenya" | country=="Ethiopia" | country=="Chad" | ///
country=="Cameroon" | country=="Gabon" | country=="Mozambique" | country=="Malawi" | ///
country=="Botswana" | country=="Namibia" | country=="Zimbabwe" | country=="South Africa" | ///
country=="Nigeria" | country=="Senegal" | country=="Guinea" | country=="Sierra Leone" | ///
country=="Liberia" | country=="Ivory Coast" | country=="Ghana" | country=="Gambia" | ///
country=="Guinea-Bissau" | country=="Togo" | country=="Benin" | country=="Burkina Faso" | ///
country=="Eritrea" | country=="Djibouti" | country=="Somalia" | country=="Lesotho" | ///
country=="Swaziland" | country=="Niger" | country=="Mali"
drop if group==.

gen df_conflict_flag=1 if conflict_count>0
replace df_conflict_flag=0 if df_conflict_flag==.
gen df_civilians_flag=1 if civilians>0
replace df_civilians_flag=0 if civilians==0
gen df_battles_flag=1 if battles>0
replace df_battles_flag=0 if battles==0
gen df_riots_protest_flag=1 if riots_protest>0
replace df_riots_protest_flag=0 if riots_protest==0
gen df_other_flag=1 if other>0
replace df_other_flag=0 if other==0
gen df_deadly_conflict_flag=1 if fatalities>0
replace df_deadly_conflict_flag=0 if fatalities==0

collapse (mean) df_conflict_flag df_civilians_flag df_battles_flag ///
df_riots_protest_flag df_other_flag df_deadly_conflict_flag, by(year month group)

save "es_df_trends.dta", replace

merge 1:1 year month group using "es_drc_trends.dta"
gen year_month = string(year, "%04.0f") + string(month, "%02.0f")
destring year_month, replace
drop _merge
reshape wide df_conflict_flag df_civilians_flag df_battles_flag ///
df_riots_protest_flag df_other_flag df_deadly_conflict_flag conflict_flag ///
civilians_flag battles_flag riots_protest_flag other_flag ///
deadly_conflict_flag, i(year_month) j(group)
tostring year_month, replace
encode year_month, generate(time)

line conflict_flag1 conflict_flag0 df_conflict_flag1 time, lpattern(solid dash solid) ///
scheme(s1mono) xline(35) ylabel(0(0.25)0.5, angle(horizontal)) title("A", position(10)) ///
xtitle("Month and Year") ytitle("Probability") legend(label(1 "DRC")) legend(label(2 "Covered Countries")) ///
legend(label(3 "Non-Covered Countries"))


*************************************
** Diff-in-diff Regression Model 1 **
*************************************
* DRC only panel
use "es_conflict_panel.dta", clear

drop group

gen group=1 if country=="Democratic Republic of Congo"
replace group=0 if country=="Kenya" | country=="Ethiopia" | country=="Chad" | ///
country=="Cameroon" | country=="Gabon" | country=="Mozambique" | country=="Malawi" | ///
country=="Botswana" | country=="Namibia" | country=="Zimbabwe" | country=="South Africa" | ///
country=="Nigeria" | country=="Senegal" | country=="Guinea" | country=="Sierra Leone" | ///
country=="Liberia" | country=="Ivory Coast" | country=="Ghana" | country=="Gambia" | ///
country=="Guinea-Bissau" | country=="Togo" | country=="Benin" | country=="Burkina Faso" | ///
country=="Eritrea" | country=="Djibouti" | country=="Lesotho" | ///
country=="Swaziland" | country=="Niger" | country=="Mali"
drop if group==.

drop year_month
gen year_month = string(year, "%04.0f") + string(month, "%02.0f")
destring year_month, replace

gen post_suspend=1 if year_month>201704
replace post_suspend=0 if post_suspend==.
gen conflict_flag=1 if conflict_count>0
replace conflict_flag=0 if conflict_flag==.
gen civilians_flag=1 if civilians>0
replace civilians_flag=0 if civilians==0
gen battles_flag=1 if battles>0
replace battles_flag=0 if battles==0
gen riots_protest_flag=1 if riots_protest>0
replace riots_protest_flag=0 if riots_protest==0
gen other_flag=1 if other>0
replace other_flag=0 if other==0
gen deadly_conflict_flag=1 if fatalities>0
replace deadly_conflict_flag=0 if fatalities==0
gen did = group*post_suspend
encode country, generate(country_id)
egen country_admin1 = concat(country admin1)
encode country_admin1, generate(admin1_id)
egen country_admin1_2 = concat(country admin1 admin2)
encode country_admin1_2, generate(admin2_id)
set matsize 10000

* Specification (1) Panel A

reg conflict_flag did i.year_month i.admin1_id, vce(cluster country_id)

reg civilians_flag did i.year_month i.admin1_id, vce(cluster country_id)

reg battles_flag did i.year_month i.admin1_id, vce(cluster country_id)

reg riots_protest_flag did i.year_month i.admin1_id, vce(cluster country_id)

reg deadly_conflict_flag did i.year_month i.admin1_id, vce(cluster country_id)


* Summary Statistics for DRC
sum conflict_flag if post_suspend==0 & group==1
sum civilians_flag if post_suspend==0 & group==1
sum battles_flag if post_suspend==0 & group==1
sum riots_protest_flag if post_suspend==0 & group==1
sum deadly_conflict_flag if post_suspend==0 & group==1

* All Dodd Frank countries panel
use "\es_conflict_panel.dta", clear

drop group

gen group=1 if country=="Uganda" | country=="Rwanda" | country=="Burundi" | ///
country=="Tanzania" |  | country=="Zambia" | ///
country=="Angola" | country=="Republic of Congo" | ///
country=="Central African Republic" | country=="Democratic Republic of Congo"
replace group=0 if country=="Kenya" | country=="Ethiopia" | country=="Chad" | ///
country=="Cameroon" | country=="Gabon" | country=="Mozambique" | country=="Malawi" | ///
country=="Botswana" | country=="Namibia" | country=="Zimbabwe" | country=="South Africa" | ///
country=="Nigeria" | country=="Senegal" | country=="Guinea" | country=="Sierra Leone" | ///
country=="Liberia" | country=="Ivory Coast" | country=="Ghana" | country=="Gambia" | ///
country=="Guinea-Bissau" | country=="Togo" | country=="Benin" | country=="Burkina Faso" | ///
country=="Eritrea" | country=="Djibouti" | country=="Lesotho" | ///
country=="Swaziland" | country=="Niger" | country=="Mali"
drop if group==.

drop year_month
gen year_month = string(year, "%04.0f") + string(month, "%02.0f")
destring year_month, replace

gen post_suspend=1 if year_month>201704
replace post_suspend=0 if post_suspend==.
gen conflict_flag=1 if conflict_count>0
replace conflict_flag=0 if conflict_flag==.
gen civilians_flag=1 if civilians>0
replace civilians_flag=0 if civilians==0
gen battles_flag=1 if battles>0
replace battles_flag=0 if battles==0
gen riots_protest_flag=1 if riots_protest>0
replace riots_protest_flag=0 if riots_protest==0
gen other_flag=1 if other>0
replace other_flag=0 if other==0
gen deadly_conflict_flag=1 if fatalities>0
replace deadly_conflict_flag=0 if fatalities==0
gen did = group*post_suspend
encode country, generate(country_id)
egen country_admin1 = concat(country admin1)
encode country_admin1, generate(admin1_id)
egen country_admin1_2 = concat(country admin1 admin2)
encode country_admin1_2, generate(admin2_id)
set matsize 10000

* Specification (1) Panel B

reg conflict_flag did i.year_month i.admin1_id, vce(cluster country_id)

reg civilians_flag did i.year_month i.admin1_id, vce(cluster country_id)

reg battles_flag did i.year_month i.admin1_id, vce(cluster country_id)

reg other_flag did i.year_month i.admin1_id, vce(cluster country_id)

reg deadly_conflict_flag did i.year_month i.admin1_id, vce(cluster country_id)


* Summary Statistics for Covered Countries
sum conflict_flag if post_suspend==0 & group==1
sum civilians_flag if post_suspend==0 & group==1
sum battles_flag if post_suspend==0 & group==1
sum riots_protest_flag if post_suspend==0 & group==1
sum deadly_conflict_flag if post_suspend==0 & group==1

* Placebo tests

* A: All conflict
use "es_conflict_panel.dta", clear
drop if country=="Uganda" | country=="Rwanda" | country=="Burundi" | ///
country=="Tanzania" |  | country=="Zambia" | country=="Angola" | ///
country=="Republic of Congo" | country=="Central African Republic" | country=="Somalia"
save "es_conflict_panel_placebo.dta", replace
collapse (mean) group, by(country)
drop group
gen effect = .
egen country_num = group(country)
su country_num, meanonly
foreach i of num 1/`r(max)' {
	preserve
	
	use "es_conflict_panel_placebo.dta", clear
	egen country_num = group(country)
	
	drop group
	gen group=1 if country_num==`i'
	replace group=0 if country_num!=`i'
	drop if group==.

	drop year_month
	gen year_month = string(year, "%04.0f") + string(month, "%02.0f")
	destring year_month, replace

	gen post_suspend=1 if year_month>201704
	replace post_suspend=0 if post_suspend==.
	gen conflict_flag=1 if conflict_count>0
	replace conflict_flag=0 if conflict_flag==.
	gen civilians_flag=1 if civilians>0
	replace civilians_flag=0 if civilians==0
	gen battles_flag=1 if battles>0
	replace battles_flag=0 if battles==0
	gen other_flag=1 if other>0
	replace other_flag=0 if other==0
	gen deadly_conflict_flag=1 if fatalities>0
	replace deadly_conflict_flag=0 if fatalities==0
	gen did = group*post_suspend
	encode country, generate(country_id)
	egen country_admin1 = concat(country admin1)
	encode country_admin1, generate(admin1_id)
	egen country_admin1_2 = concat(country admin1 admin2)
	encode country_admin1_2, generate(admin2_id)
	set matsize 10000

	reg conflict_flag did i.year_month i.admin1_id, vce(cluster admin2_id)
	
	local effect = _b[did]
	
	restore
	
	replace effect = `effect' in `i'
}
*
save "es_placebo_all_conflict.dta", replace
use "es_placebo_all_conflict.dta", clear
drop if country=="Democratic Republic of Congo"
sum effect, detail
histogram effect , freq bin(31) scheme(s1mono) xline(0.007) lcolor(black) ///
xline(-0.046, lpattern(dash)) xline(0.093, lpattern(dash)) title("A", position(10)) ///
xtitle("Placebo Estimates") ylabel(, angle(horizontal))
graph save "es_drc_all_conflict.gph", replace

* B: Civilians
use "\es_conflict_panel.dta", clear
drop if country=="Uganda" | country=="Rwanda" | country=="Burundi" | ///
country=="Tanzania" | country=="Zambia" | country=="Angola" | ///
country=="Republic of Congo" | country=="Central African Republic" | country=="Somalia"
save "es_conflict_panel_placebo.dta", replace
collapse (mean) group, by(country)
drop group
gen effect = .
egen country_num = group(country)
su country_num, meanonly
foreach i of num 1/`r(max)' {
	preserve
	
	use "es_conflict_panel_placebo.dta", clear
	egen country_num = group(country)
	
	drop group
	gen group=1 if country_num==`i'
	replace group=0 if country_num!=`i'
	drop if group==.

	drop year_month
	gen year_month = string(year, "%04.0f") + string(month, "%02.0f")
	destring year_month, replace

	gen post_suspend=1 if year_month>201704
	replace post_suspend=0 if post_suspend==.
	gen conflict_flag=1 if conflict_count>0
	replace conflict_flag=0 if conflict_flag==.
	gen civilians_flag=1 if civilians>0
	replace civilians_flag=0 if civilians==0
	gen battles_flag=1 if battles>0
	replace battles_flag=0 if battles==0
	gen other_flag=1 if other>0
	replace other_flag=0 if other==0
	gen deadly_conflict_flag=1 if fatalities>0
	replace deadly_conflict_flag=0 if fatalities==0
	gen did = group*post_suspend
	encode country, generate(country_id)
	egen country_admin1 = concat(country admin1)
	encode country_admin1, generate(admin1_id)
	egen country_admin1_2 = concat(country admin1 admin2)
	encode country_admin1_2, generate(admin2_id)
	set matsize 10000

	reg civilians_flag did i.year_month i.admin1_id, vce(cluster admin2_id)
	
	local effect = _b[did]
	
	restore
	
	replace effect = `effect' in `i'
}
*
save "es_placebo_civilians.dta", replace
use "es_placebo_civilians.dta", clear
drop if country=="Democratic Republic of Congo"
sum effect, detail
histogram effect , freq bin(31) scheme(s1mono) xline(0.027) lcolor(black) ///
xline(-0.036, lpattern(dash)) xline(0.082, lpattern(dash))title("B", position(10)) ///
xtitle("Placebo Estimates") ylabel(, angle(horizontal))
graph save "es_drc_civilians.gph", replace

* C: Battles
use "Y:\Research\Dodd Frank\Enforcement suspension\es_conflict_panel.dta", clear
drop if country=="Uganda" | country=="Rwanda" | country=="Burundi" | ///
country=="Tanzania" | country=="Zambia" | country=="Angola" | ///
country=="Republic of Congo" | country=="Central African Republic" | country=="Somalia"
save "es_conflict_panel_placebo.dta", replace
collapse (mean) group, by(country)
drop group
gen effect = .
egen country_num = group(country)
su country_num, meanonly
foreach i of num 1/`r(max)' {
	preserve
	
	use "es_conflict_panel_placebo.dta", clear
	egen country_num = group(country)
	
	drop group
	gen group=1 if country_num==`i'
	replace group=0 if country_num!=`i'
	drop if group==.

	drop year_month
	gen year_month = string(year, "%04.0f") + string(month, "%02.0f")
	destring year_month, replace

	gen post_suspend=1 if year_month>201704
	replace post_suspend=0 if post_suspend==.
	gen conflict_flag=1 if conflict_count>0
	replace conflict_flag=0 if conflict_flag==.
	gen civilians_flag=1 if civilians>0
	replace civilians_flag=0 if civilians==0
	gen battles_flag=1 if battles>0
	replace battles_flag=0 if battles==0
	gen other_flag=1 if other>0
	replace other_flag=0 if other==0
	gen deadly_conflict_flag=1 if fatalities>0
	replace deadly_conflict_flag=0 if fatalities==0
	gen did = group*post_suspend
	encode country, generate(country_id)
	egen country_admin1 = concat(country admin1)
	encode country_admin1, generate(admin1_id)
	egen country_admin1_2 = concat(country admin1 admin2)
	encode country_admin1_2, generate(admin2_id)
	set matsize 10000

	reg battles_flag did i.year_month i.admin1_id, vce(cluster admin2_id)
	
	local effect = _b[did]
	
	restore
	
	replace effect = `effect' in `i'
}
*
save "es_placebo_battles.dta", replace
use "es_placebo_battles.dta", clear
drop if country=="Democratic Republic of Congo"
sum effect, detail
histogram effect , freq bin(31) scheme(s1mono) xline(0.010) lcolor(black) ///
xline(-0.015, lpattern(dash)) xline(0.056, lpattern(dash)) title("C", position(10)) ///
xtitle("Placebo Estimates") ylabel(, angle(horizontal))
graph save "es_drc_battles.gph", replace

* D: Riots and Protests
use "es_conflict_panel.dta", clear
drop if country=="Uganda" | country=="Rwanda" | country=="Burundi" | ///
country=="Tanzania" | country=="Zambia" | country=="Angola" | ///
country=="Republic of Congo" | country=="Central African Republic" | country=="Somalia"
save "es_conflict_panel_placebo.dta", replace
collapse (mean) group, by(country)
drop group
gen effect = .
egen country_num = group(country)
su country_num, meanonly
foreach i of num 1/`r(max)' {
	preserve
	
	use "es_conflict_panel_placebo.dta", clear
	egen country_num = group(country)
	
	drop group
	gen group=1 if country_num==`i'
	replace group=0 if country_num!=`i'
	drop if group==.

	drop year_month
	gen year_month = string(year, "%04.0f") + string(month, "%02.0f")
	destring year_month, replace

	gen post_suspend=1 if year_month>201704
	replace post_suspend=0 if post_suspend==.
	gen conflict_flag=1 if conflict_count>0
	replace conflict_flag=0 if conflict_flag==.
	gen civilians_flag=1 if civilians>0
	replace civilians_flag=0 if civilians==0
	gen battles_flag=1 if battles>0
	replace battles_flag=0 if battles==0
	gen riots_protest_flag=1 if riots_protest>0
	replace riots_protest_flag=0 if riots_protest==0
	gen other_flag=1 if other>0
	replace other_flag=0 if other==0
	gen deadly_conflict_flag=1 if fatalities>0
	replace deadly_conflict_flag=0 if fatalities==0
	gen did = group*post_suspend
	encode country, generate(country_id)
	egen country_admin1 = concat(country admin1)
	encode country_admin1, generate(admin1_id)
	egen country_admin1_2 = concat(country admin1 admin2)
	encode country_admin1_2, generate(admin2_id)
	set matsize 10000

	reg other_flag did i.year_month i.admin1_id, vce(cluster admin2_id)
	
	local effect = _b[did]
	
	restore
	
	replace effect = `effect' in `i'
}
*
save "es_placebo_riots_protest.dta", replace
use "es_placebo_riots_protest.dta", clear
drop if country=="Democratic Republic of Congo"
sum effect, detail
histogram effect , freq bin(31) scheme(s1mono) xline(-0.030) lcolor(black) ///
xline(-0.012, lpattern(dash)) xline(0.027, lpattern(dash)) title("D", position(10)) ///
xscale(range(-0.04 -0.02 0 0.02 0.04)) xtitle("Placebo Estimates") ylabel(, angle(horizontal))
graph save "es_drc_riots_protest.gph", replace

* E: Deadly Conflict
use "es_conflict_panel.dta", clear
drop if country=="Uganda" | country=="Rwanda" | country=="Burundi" | ///
country=="Tanzania" | country=="Zambia" | country=="Angola" | ///
country=="Republic of Congo" | country=="Central African Republic" | country=="Somalia"
save "Y:\Research\Dodd Frank\Enforcement suspension\es_conflict_panel_placebo.dta", replace
collapse (mean) group, by(country)
drop group
gen effect = .
egen country_num = group(country)
su country_num, meanonly
foreach i of num 1/`r(max)' {
	preserve
	
	use "es_conflict_panel_placebo.dta", clear
	egen country_num = group(country)
	
	drop group
	gen group=1 if country_num==`i'
	replace group=0 if country_num!=`i'
	drop if group==.

	drop year_month
	gen year_month = string(year, "%04.0f") + string(month, "%02.0f")
	destring year_month, replace

	gen post_suspend=1 if year_month>201704
	replace post_suspend=0 if post_suspend==.
	gen conflict_flag=1 if conflict_count>0
	replace conflict_flag=0 if conflict_flag==.
	gen civilians_flag=1 if civilians>0
	replace civilians_flag=0 if civilians==0
	gen battles_flag=1 if battles>0
	replace battles_flag=0 if battles==0
	gen other_flag=1 if other>0
	replace other_flag=0 if other==0
	gen deadly_conflict_flag=1 if fatalities>0
	replace deadly_conflict_flag=0 if fatalities==0
	gen did = group*post_suspend
	encode country, generate(country_id)
	egen country_admin1 = concat(country admin1)
	encode country_admin1, generate(admin1_id)
	egen country_admin1_2 = concat(country admin1 admin2)
	encode country_admin1_2, generate(admin2_id)
	set matsize 10000

	reg deadly_conflict_flag did i.year_month i.admin1_id, vce(cluster admin2_id)
	
	local effect = _b[did]
	
	restore
	
	replace effect = `effect' in `i'
}
*
save "es_placebo_deadly.dta", replace
use "es_placebo_deadly.dta", clear
drop if country=="Democratic Republic of Congo"
sum effect, detail
histogram effect , freq bin(31) scheme(s1mono) xline(0.014) lcolor(black) ///
xline(-0.020, lpattern(dash)) xline(0.080, lpattern(dash)) title("E", position(10)) xtitle("Placebo Estimates") ylabel(, angle(horizontal))
graph save "es_drc_deadly.gph", replace

gr combine es_drc_all_conflict.gph es_drc_civilians.gph es_drc_battles.gph ///
es_drc_riots_protest.gph es_drc_deadly.gph, scheme(s1mono) cols(2)



*************************************
** Diff-in-diff Regression Model 2 **
*************************************
* DRC only 
use "es_conflict_panel.dta", clear

drop group

gen group=1 if country=="Democratic Republic of Congo"
replace group=0 if country=="Kenya" | country=="Ethiopia" | country=="Chad" | ///
country=="Cameroon" | country=="Gabon" | country=="Mozambique" | country=="Malawi" | ///
country=="Botswana" | country=="Namibia" | country=="Zimbabwe" | country=="South Africa" | ///
country=="Nigeria" | country=="Senegal" | country=="Guinea" | country=="Sierra Leone" | ///
country=="Liberia" | country=="Ivory Coast" | country=="Ghana" | country=="Gambia" | ///
country=="Guinea-Bissau" | country=="Togo" | country=="Benin" | country=="Burkina Faso" | ///
country=="Eritrea" | country=="Djibouti" | country=="Lesotho" | ///
country=="Swaziland" | country=="Niger" | country=="Mali"
drop if group==.

drop year_month
gen year_month = string(year, "%04.0f") + string(month, "%02.0f")
destring year_month, replace

gen post_suspend=1 if year_month>201704
replace post_suspend=0 if post_suspend==.
gen conflict_flag=1 if conflict_count>0
replace conflict_flag=0 if conflict_flag==.
gen civilians_flag=1 if civilians>0
replace civilians_flag=0 if civilians==0
gen battles_flag=1 if battles>0
replace battles_flag=0 if battles==0
gen riots_protest_flag=1 if riots_protest>0
replace riots_protest_flag=0 if riots_protest==0
gen other_flag=1 if other>0
replace other_flag=0 if other==0
gen deadly_conflict_flag=1 if fatalities>0
replace deadly_conflict_flag=0 if fatalities==0
gen did = group*post_suspend
encode country, generate(country_id)
egen country_admin1 = concat(country admin1)
encode country_admin1, generate(admin1_id)
egen country_admin1_2 = concat(country admin1 admin2)
encode country_admin1_2, generate(admin2_id)
set matsize 10000


* Specification (2)
gen b201405 = 1 if year_month==201405 & group==1
replace b201405 = 0 if b201405==.
gen b201406 = 1 if year_month==201406 & group==1
replace b201406 = 0 if b201406==.
gen b201407 = 1 if year_month==201407 & group==1
replace b201407 = 0 if b201407==.
gen b201408 = 1 if year_month==201408 & group==1
replace b201408 = 0 if b201408==.
gen b201409 = 1 if year_month==201409 & group==1
replace b201409 = 0 if b201409==.
gen b201410 = 1 if year_month==201410 & group==1
replace b201410 = 0 if b201410==.
gen b201411 = 1 if year_month==201411 & group==1
replace b201411 = 0 if b201411==.
gen b201412 = 1 if year_month==201412 & group==1
replace b201412 = 0 if b201412==.
gen b201501 = 1 if year_month==201501 & group==1
replace b201501 = 0 if b201501==.
gen b201502 = 1 if year_month==201502 & group==1
replace b201502 = 0 if b201502==.
gen b201503 = 1 if year_month==201503 & group==1
replace b201503 = 0 if b201503==.
gen b201504 = 1 if year_month==201504 & group==1
replace b201504 = 0 if b201504==.
gen b201505 = 1 if year_month==201505 & group==1
replace b201505 = 0 if b201505==.
gen b201506 = 1 if year_month==201506 & group==1
replace b201506 = 0 if b201506==.
gen b201507 = 1 if year_month==201507 & group==1
replace b201507 = 0 if b201507==.
gen b201508 = 1 if year_month==201508 & group==1
replace b201508 = 0 if b201508==.
gen b201509 = 1 if year_month==201509 & group==1
replace b201509 = 0 if b201509==.
gen b201510 = 1 if year_month==201510 & group==1
replace b201510 = 0 if b201510==.
gen b201511 = 1 if year_month==201511 & group==1
replace b201511 = 0 if b201511==.
gen b201512 = 1 if year_month==201512 & group==1
replace b201512 = 0 if b201512==.
gen b201601 = 1 if year_month==201601 & group==1
replace b201601 = 0 if b201601==.
gen b201602 = 1 if year_month==201602 & group==1
replace b201602 = 0 if b201602==.
gen b201603 = 1 if year_month==201603 & group==1
replace b201603 = 0 if b201603==.
gen b201604 = 1 if year_month==201604 & group==1
replace b201604 = 0 if b201604==.
gen b201605 = 1 if year_month==201605 & group==1
replace b201605 = 0 if b201605==.
gen b201606 = 1 if year_month==201606 & group==1
replace b201606 = 0 if b201606==.
gen b201607 = 1 if year_month==201607 & group==1
replace b201607 = 0 if b201607==.
gen b201608 = 1 if year_month==201608 & group==1
replace b201608 = 0 if b201608==.
gen b201609 = 1 if year_month==201609 & group==1
replace b201609 = 0 if b201609==.
gen b201610 = 1 if year_month==201610 & group==1
replace b201610 = 0 if b201610==.
gen b201611 = 1 if year_month==201611 & group==1
replace b201611 = 0 if b201611==.
gen b201612 = 1 if year_month==201612 & group==1
replace b201612 = 0 if b201612==.
gen b201701 = 1 if year_month==201701 & group==1
replace b201701 = 0 if b201701==.
gen b201702 = 1 if year_month==201702 & group==1
replace b201702 = 0 if b201702==.
gen b201703 = 1 if year_month==201703 & group==1
replace b201703 = 0 if b201703==.
gen b201704 = 1 if year_month==201704 & group==1
replace b201704 = 0 if b201704==.
gen b201705 = 1 if year_month==201705 & group==1
replace b201705 = 0 if b201705==.
gen b201706 = 1 if year_month==201706 & group==1
replace b201706 = 0 if b201706==.
gen b201707 = 1 if year_month==201707 & group==1
replace b201707 = 0 if b201707==.
gen b201708 = 1 if year_month==201708 & group==1
replace b201708 = 0 if b201708==.
gen b201709 = 1 if year_month==201709 & group==1
replace b201709 = 0 if b201709==.
gen b201710 = 1 if year_month==201710 & group==1
replace b201710 = 0 if b201710==.
gen b201711 = 1 if year_month==201711 & group==1
replace b201711 = 0 if b201711==.
gen b201712 = 1 if year_month==201712 & group==1
replace b201712 = 0 if b201712==.
gen b201801 = 1 if year_month==201801 & group==1
replace b201801 = 0 if b201801==.
gen b201802 = 1 if year_month==201802 & group==1
replace b201802 = 0 if b201802==.
gen b201803 = 1 if year_month==201803 & group==1
replace b201803 = 0 if b201803==.
gen b201804 = 1 if year_month==201804 & group==1
replace b201804 = 0 if b201804==.
gen b201805 = 1 if year_month==201805 & group==1
replace b201805 = 0 if b201805==.
gen b201806 = 1 if year_month==201806 & group==1
replace b201806 = 0 if b201806==.
gen b201807 = 1 if year_month==201807 & group==1
replace b201807 = 0 if b201807==.
gen b201808 = 1 if year_month==201808 & group==1
replace b201808 = 0 if b201808==.
gen b201809 = 1 if year_month==201809 & group==1
replace b201809 = 0 if b201809==.


reg conflict_flag b201406 b201409 b201412 b201503 b201506 b201509 b201512 b201603 ///
b201606 b201609 b201612 b201703 b201706 b201709 b201712 b201803 b201806 b201809 ///
i.year_month i.admin1_id, vce(cluster country_id)

coefplot, vertical keep(b201406 b201409 b201412 b201503 b201506 /// 
b201509 b201512 b201603 b201606 b201609 b201612 b201703 b201706 b201709 b201712 ///
b201803 b201806 b201809) yline(0) scheme(s1mono) rename (b201406 = 2014m6  ///
b201409 = 2014m9 b201412 = 2014m12 b201503 = 2015m3 b201506 = 2015m6 ///
b201509 = 2015m9 b201512 = 2015m12 b201603 = 2016m3 ///
b201606 = 2016m6 b201609 = 2016m9 b201612 = 2016m12 ///
b201703 = 2017m3 b201706 = 2017m6 b201709 = 2017m9 b201712 = 2017m12 ///
b201803 = 2018m3 b201806 = 2018m6 b201809 = 2018m9) xline(12.3, lpattern(dash)) title("A", position(10)) xtitle("Year") ///
ytitle("Effect Size") ylabel(, angle(horizontal)) xlabel(, angle(vertical))
graph save "es_drc_model2_all_conflict.gph", replace

reg civilians_flag b201406 b201409 b201412 b201503 b201506 b201509 b201512 b201603 ///
b201606 b201609 b201612 b201703 b201706 b201709 b201712 b201803 b201806 b201809 ///
i.year_month i.admin1_id, vce(cluster country_id)

coefplot, vertical keep(b201406 b201409 b201412 b201503 b201506 /// 
b201509 b201512 b201603 b201606 b201609 b201612 b201703 b201706 b201709 b201712 ///
b201803 b201806 b201809) yline(0) scheme(s1mono) rename (b201406 = 2014m6  ///
b201409 = 2014m9 b201412 = 2014m12 b201503 = 2015m3 b201506 = 2015m6 ///
b201509 = 2015m9 b201512 = 2015m12 b201603 = 2016m3 ///
b201606 = 2016m6 b201609 = 2016m9 b201612 = 2016m12 ///
b201703 = 2017m3 b201706 = 2017m6 b201709 = 2017m9 b201712 = 2017m12 ///
b201803 = 2018m3 b201806 = 2018m6 b201809 = 2018m9) xline(12.3, lpattern(dash)) title("B", position(10)) xtitle("Year") ///
ytitle("Effect Size") ylabel(, angle(horizontal)) xlabel(, angle(vertical))
graph save "es_drc_model2_civilians.gph", replace

reg battles_flag b201406 b201409 b201412 b201503 b201506 b201509 b201512 b201603 ///
b201606 b201609 b201612 b201703 b201706 b201709 b201712 b201803 b201806 b201809 ///
i.year_month i.admin1_id, vce(cluster country_id)

coefplot, vertical keep(b201406 b201409 b201412 b201503 b201506 /// 
b201509 b201512 b201603 b201606 b201609 b201612 b201703 b201706 b201709 b201712 ///
b201803 b201806 b201809) yline(0) scheme(s1mono) rename (b201406 = 2014m6  ///
b201409 = 2014m9 b201412 = 2014m12 b201503 = 2015m3 b201506 = 2015m6 ///
b201509 = 2015m9 b201512 = 2015m12 b201603 = 2016m3 ///
b201606 = 2016m6 b201609 = 2016m9 b201612 = 2016m12 ///
b201703 = 2017m3 b201706 = 2017m6 b201709 = 2017m9 b201712 = 2017m12 ///
b201803 = 2018m3 b201806 = 2018m6 b201809 = 2018m9) xline(12.3, lpattern(dash)) title("C", position(10)) xtitle("Year") ///
ytitle("Effect Size") ylabel(, angle(horizontal)) xlabel(, angle(vertical))
graph save "es_drc_model2_battles.gph", replace

reg riots_protest_flag b201406 b201409 b201412 b201503 b201506 b201509 b201512 b201603 ///
b201606 b201609 b201612 b201703 b201706 b201709 b201712 b201803 b201806 b201809 ///
i.year_month i.admin1_id, vce(cluster country_id)

coefplot, vertical keep(b201406 b201409 b201412 b201503 b201506 /// 
b201509 b201512 b201603 b201606 b201609 b201612 b201703 b201706 b201709 b201712 ///
b201803 b201806 b201809) yline(0) scheme(s1mono) rename (b201406 = 2014m6  ///
b201409 = 2014m9 b201412 = 2014m12 b201503 = 2015m3 b201506 = 2015m6 ///
b201509 = 2015m9 b201512 = 2015m12 b201603 = 2016m3 ///
b201606 = 2016m6 b201609 = 2016m9 b201612 = 2016m12 ///
b201703 = 2017m3 b201706 = 2017m6 b201709 = 2017m9 b201712 = 2017m12 ///
b201803 = 2018m3 b201806 = 2018m6 b201809 = 2018m9) xline(12.3, lpattern(dash)) title("D", position(10)) xtitle("Year") ///
ytitle("Effect Size") ylabel(, angle(horizontal)) xlabel(, angle(vertical))
graph save "es_drc_model2_riots_protest.gph", replace

reg deadly_conflict_flag b201406 b201409 b201412 b201503 b201506 b201509 b201512 b201603 ///
b201606 b201609 b201612 b201703 b201706 b201709 b201712 b201803 b201806 b201809 ///
i.year_month i.admin1_id, vce(cluster country_id)

coefplot, vertical keep(b201406 b201409 b201412 b201503 b201506 /// 
b201509 b201512 b201603 b201606 b201609 b201612 b201703 b201706 b201709 b201712 ///
b201803 b201806 b201809) yline(0) scheme(s1mono) rename (b201406 = 2014m6  ///
b201409 = 2014m9 b201412 = 2014m12 b201503 = 2015m3 b201506 = 2015m6 ///
b201509 = 2015m9 b201512 = 2015m12 b201603 = 2016m3 ///
b201606 = 2016m6 b201609 = 2016m9 b201612 = 2016m12 ///
b201703 = 2017m3 b201706 = 2017m6 b201709 = 2017m9 b201712 = 2017m12 ///
b201803 = 2018m3 b201806 = 2018m6 b201809 = 2018m9) xline(12.3, lpattern(dash)) title("E", position(10)) xtitle("Year") ///
ytitle("Effect Size") ylabel(, angle(horizontal)) xlabel(, angle(vertical))
graph save "es_drc_model2_deadly.gph", replace

gr combine es_drc_model2_all_conflict.gph es_drc_model2_civilians.gph ///
es_drc_model2_battles.gph es_drc_model2_riots_protest.gph ///
es_drc_model2_deadly.gph, scheme(s1mono) cols(2) ycommon

* All Dodd Frank
use "es_conflict_panel.dta", clear

drop group

gen group=1 if country=="Uganda" | country=="Rwanda" | country=="Burundi" | ///
country=="Tanzania" |  | country=="Zambia" | ///
country=="Angola" | country=="Republic of Congo" | ///
country=="Central African Republic" | country=="Democratic Republic of Congo"
replace group=0 if country=="Kenya" | country=="Ethiopia" | country=="Chad" | ///
country=="Cameroon" | country=="Gabon" | country=="Mozambique" | country=="Malawi" | ///
country=="Botswana" | country=="Namibia" | country=="Zimbabwe" | country=="South Africa" | ///
country=="Nigeria" | country=="Senegal" | country=="Guinea" | country=="Sierra Leone" | ///
country=="Liberia" | country=="Ivory Coast" | country=="Ghana" | country=="Gambia" | ///
country=="Guinea-Bissau" | country=="Togo" | country=="Benin" | country=="Burkina Faso" | ///
country=="Eritrea" | country=="Djibouti" | country=="Lesotho" | ///
country=="Swaziland" | country=="Niger" | country=="Mali"
drop if group==.

drop year_month
gen year_month = string(year, "%04.0f") + string(month, "%02.0f")
destring year_month, replace

gen post_suspend=1 if year_month>201704
replace post_suspend=0 if post_suspend==.
gen conflict_flag=1 if conflict_count>0
replace conflict_flag=0 if conflict_flag==.
gen civilians_flag=1 if civilians>0
replace civilians_flag=0 if civilians==0
gen battles_flag=1 if battles>0
replace battles_flag=0 if battles==0
gen riots_protest_flag=1 if riots_protest>0
replace riots_protest_flag=0 if riots_protest==0
gen other_flag=1 if other>0
replace other_flag=0 if other==0
gen deadly_conflict_flag=1 if fatalities>0
replace deadly_conflict_flag=0 if fatalities==0
gen did = group*post_suspend
encode country, generate(country_id)
egen country_admin1 = concat(country admin1)
encode country_admin1, generate(admin1_id)
egen country_admin1_2 = concat(country admin1 admin2)
encode country_admin1_2, generate(admin2_id)
set matsize 10000


* Specification (2)
gen b201405 = 1 if year_month==201405 & group==1
replace b201405 = 0 if b201405==.
gen b201406 = 1 if year_month==201406 & group==1
replace b201406 = 0 if b201406==.
gen b201407 = 1 if year_month==201407 & group==1
replace b201407 = 0 if b201407==.
gen b201408 = 1 if year_month==201408 & group==1
replace b201408 = 0 if b201408==.
gen b201409 = 1 if year_month==201409 & group==1
replace b201409 = 0 if b201409==.
gen b201410 = 1 if year_month==201410 & group==1
replace b201410 = 0 if b201410==.
gen b201411 = 1 if year_month==201411 & group==1
replace b201411 = 0 if b201411==.
gen b201412 = 1 if year_month==201412 & group==1
replace b201412 = 0 if b201412==.
gen b201501 = 1 if year_month==201501 & group==1
replace b201501 = 0 if b201501==.
gen b201502 = 1 if year_month==201502 & group==1
replace b201502 = 0 if b201502==.
gen b201503 = 1 if year_month==201503 & group==1
replace b201503 = 0 if b201503==.
gen b201504 = 1 if year_month==201504 & group==1
replace b201504 = 0 if b201504==.
gen b201505 = 1 if year_month==201505 & group==1
replace b201505 = 0 if b201505==.
gen b201506 = 1 if year_month==201506 & group==1
replace b201506 = 0 if b201506==.
gen b201507 = 1 if year_month==201507 & group==1
replace b201507 = 0 if b201507==.
gen b201508 = 1 if year_month==201508 & group==1
replace b201508 = 0 if b201508==.
gen b201509 = 1 if year_month==201509 & group==1
replace b201509 = 0 if b201509==.
gen b201510 = 1 if year_month==201510 & group==1
replace b201510 = 0 if b201510==.
gen b201511 = 1 if year_month==201511 & group==1
replace b201511 = 0 if b201511==.
gen b201512 = 1 if year_month==201512 & group==1
replace b201512 = 0 if b201512==.
gen b201601 = 1 if year_month==201601 & group==1
replace b201601 = 0 if b201601==.
gen b201602 = 1 if year_month==201602 & group==1
replace b201602 = 0 if b201602==.
gen b201603 = 1 if year_month==201603 & group==1
replace b201603 = 0 if b201603==.
gen b201604 = 1 if year_month==201604 & group==1
replace b201604 = 0 if b201604==.
gen b201605 = 1 if year_month==201605 & group==1
replace b201605 = 0 if b201605==.
gen b201606 = 1 if year_month==201606 & group==1
replace b201606 = 0 if b201606==.
gen b201607 = 1 if year_month==201607 & group==1
replace b201607 = 0 if b201607==.
gen b201608 = 1 if year_month==201608 & group==1
replace b201608 = 0 if b201608==.
gen b201609 = 1 if year_month==201609 & group==1
replace b201609 = 0 if b201609==.
gen b201610 = 1 if year_month==201610 & group==1
replace b201610 = 0 if b201610==.
gen b201611 = 1 if year_month==201611 & group==1
replace b201611 = 0 if b201611==.
gen b201612 = 1 if year_month==201612 & group==1
replace b201612 = 0 if b201612==.
gen b201701 = 1 if year_month==201701 & group==1
replace b201701 = 0 if b201701==.
gen b201702 = 1 if year_month==201702 & group==1
replace b201702 = 0 if b201702==.
gen b201703 = 1 if year_month==201703 & group==1
replace b201703 = 0 if b201703==.
gen b201704 = 1 if year_month==201704 & group==1
replace b201704 = 0 if b201704==.
gen b201705 = 1 if year_month==201705 & group==1
replace b201705 = 0 if b201705==.
gen b201706 = 1 if year_month==201706 & group==1
replace b201706 = 0 if b201706==.
gen b201707 = 1 if year_month==201707 & group==1
replace b201707 = 0 if b201707==.
gen b201708 = 1 if year_month==201708 & group==1
replace b201708 = 0 if b201708==.
gen b201709 = 1 if year_month==201709 & group==1
replace b201709 = 0 if b201709==.
gen b201710 = 1 if year_month==201710 & group==1
replace b201710 = 0 if b201710==.
gen b201711 = 1 if year_month==201711 & group==1
replace b201711 = 0 if b201711==.
gen b201712 = 1 if year_month==201712 & group==1
replace b201712 = 0 if b201712==.
gen b201801 = 1 if year_month==201801 & group==1
replace b201801 = 0 if b201801==.
gen b201802 = 1 if year_month==201802 & group==1
replace b201802 = 0 if b201802==.
gen b201803 = 1 if year_month==201803 & group==1
replace b201803 = 0 if b201803==.
gen b201804 = 1 if year_month==201804 & group==1
replace b201804 = 0 if b201804==.
gen b201805 = 1 if year_month==201805 & group==1
replace b201805 = 0 if b201805==.
gen b201806 = 1 if year_month==201806 & group==1
replace b201806 = 0 if b201806==.
gen b201807 = 1 if year_month==201807 & group==1
replace b201807 = 0 if b201807==.
gen b201808 = 1 if year_month==201808 & group==1
replace b201808 = 0 if b201808==.
gen b201809 = 1 if year_month==201809 & group==1
replace b201809 = 0 if b201809==.


reg conflict_flag b201406 b201409 b201412 b201503 b201506 b201509 b201512 b201603 ///
b201606 b201609 b201612 b201703 b201706 b201709 b201712 b201803 b201806 b201809 ///
i.year_month i.admin1_id, vce(cluster country_id)

coefplot, vertical keep(b201406 b201409 b201412 b201503 b201506 /// 
b201509 b201512 b201603 b201606 b201609 b201612 b201703 b201706 b201709 b201712 ///
b201803 b201806 b201809) yline(0) scheme(s1mono) rename (b201406 = 2014m6  ///
b201409 = 2014m9 b201412 = 2014m12 b201503 = 2015m3 b201506 = 2015m6 ///
b201509 = 2015m9 b201512 = 2015m12 b201603 = 2016m3 ///
b201606 = 2016m6 b201609 = 2016m9 b201612 = 2016m12 ///
b201703 = 2017m3 b201706 = 2017m6 b201709 = 2017m9 b201712 = 2017m12 ///
b201803 = 2018m3 b201806 = 2018m6 b201809 = 2018m9) xline(12.3, lpattern(dash)) title("A", position(10)) xtitle("Year") ///
ytitle("Effect Size") ylabel(, angle(horizontal)) xlabel(, angle(vertical))
graph save "es_df_model2_all_conflict.gph", replace

reg civilians_flag b201406 b201409 b201412 b201503 b201506 b201509 b201512 b201603 ///
b201606 b201609 b201612 b201703 b201706 b201709 b201712 b201803 b201806 b201809 ///
i.year_month i.admin1_id, vce(cluster country_id)

coefplot, vertical keep(b201406 b201409 b201412 b201503 b201506 /// 
b201509 b201512 b201603 b201606 b201609 b201612 b201703 b201706 b201709 b201712 ///
b201803 b201806 b201809) yline(0) scheme(s1mono) rename (b201406 = 2014m6  ///
b201409 = 2014m9 b201412 = 2014m12 b201503 = 2015m3 b201506 = 2015m6 ///
b201509 = 2015m9 b201512 = 2015m12 b201603 = 2016m3 ///
b201606 = 2016m6 b201609 = 2016m9 b201612 = 2016m12 ///
b201703 = 2017m3 b201706 = 2017m6 b201709 = 2017m9 b201712 = 2017m12 ///
b201803 = 2018m3 b201806 = 2018m6 b201809 = 2018m9) xline(12.3, lpattern(dash)) title("B", position(10)) xtitle("Year") ///
ytitle("Effect Size") ylabel(, angle(horizontal)) xlabel(, angle(vertical))
graph save "es_df_model2_civilians.gph", replace

reg battles_flag b201406 b201409 b201412 b201503 b201506 b201509 b201512 b201603 ///
b201606 b201609 b201612 b201703 b201706 b201709 b201712 b201803 b201806 b201809 ///
i.year_month i.admin1_id, vce(cluster country_id)

coefplot, vertical keep(b201406 b201409 b201412 b201503 b201506 /// 
b201509 b201512 b201603 b201606 b201609 b201612 b201703 b201706 b201709 b201712 ///
b201803 b201806 b201809) yline(0) scheme(s1mono) rename (b201406 = 2014m6  ///
b201409 = 2014m9 b201412 = 2014m12 b201503 = 2015m3 b201506 = 2015m6 ///
b201509 = 2015m9 b201512 = 2015m12 b201603 = 2016m3 ///
b201606 = 2016m6 b201609 = 2016m9 b201612 = 2016m12 ///
b201703 = 2017m3 b201706 = 2017m6 b201709 = 2017m9 b201712 = 2017m12 ///
b201803 = 2018m3 b201806 = 2018m6 b201809 = 2018m9) xline(12.3, lpattern(dash)) title("C", position(10)) xtitle("Year") ///
ytitle("Effect Size") ylabel(, angle(horizontal)) xlabel(, angle(vertical))
graph save "es_df_model2_battles.gph", replace

reg riots_protest_flag b201406 b201409 b201412 b201503 b201506 b201509 b201512 b201603 ///
b201606 b201609 b201612 b201703 b201706 b201709 b201712 b201803 b201806 b201809 ///
i.year_month i.admin1_id, vce(cluster country_id)

coefplot, vertical keep(b201406 b201409 b201412 b201503 b201506 /// 
b201509 b201512 b201603 b201606 b201609 b201612 b201703 b201706 b201709 b201712 ///
b201803 b201806 b201809) yline(0) scheme(s1mono) rename (b201406 = 2014m6  ///
b201409 = 2014m9 b201412 = 2014m12 b201503 = 2015m3 b201506 = 2015m6 ///
b201509 = 2015m9 b201512 = 2015m12 b201603 = 2016m3 ///
b201606 = 2016m6 b201609 = 2016m9 b201612 = 2016m12 ///
b201703 = 2017m3 b201706 = 2017m6 b201709 = 2017m9 b201712 = 2017m12 ///
b201803 = 2018m3 b201806 = 2018m6 b201809 = 2018m9) xline(12.3, lpattern(dash)) title("D", position(10)) xtitle("Year") ///
ytitle("Effect Size") ylabel(, angle(horizontal)) xlabel(, angle(vertical))
graph save "es_df_model2_riots_protest.gph", replace

reg deadly_conflict_flag b201406 b201409 b201412 b201503 b201506 b201509 b201512 b201603 ///
b201606 b201609 b201612 b201703 b201706 b201709 b201712 b201803 b201806 b201809 ///
i.year_month i.admin1_id, vce(cluster country_id)

coefplot, vertical keep(b201406 b201409 b201412 b201503 b201506 /// 
b201509 b201512 b201603 b201606 b201609 b201612 b201703 b201706 b201709 b201712 ///
b201803 b201806 b201809) yline(0) scheme(s1mono) rename (b201406 = 2014m6  ///
b201409 = 2014m9 b201412 = 2014m12 b201503 = 2015m3 b201506 = 2015m6 ///
b201509 = 2015m9 b201512 = 2015m12 b201603 = 2016m3 ///
b201606 = 2016m6 b201609 = 2016m9 b201612 = 2016m12 ///
b201703 = 2017m3 b201706 = 2017m6 b201709 = 2017m9 b201712 = 2017m12 ///
b201803 = 2018m3 b201806 = 2018m6 b201809 = 2018m9) xline(12.3, lpattern(dash)) title("E", position(10)) xtitle("Year") ///
ytitle("Effect Size") ylabel(, angle(horizontal)) xlabel(, angle(vertical))
graph save "es_df_model2_deadly.gph", replace

gr combine es_df_model2_all_conflict.gph es_df_model2_civilians.gph ///
es_df_model2_battles.gph es_df_model2_riots_protest.gph es_df_model2_deadly.gph, ///
scheme(s1mono) cols(2) ycommon
